<template>
  <div class="view-wrapper">
    <div class="head">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
        <el-form-item label="关键词：" prop="query">
          <el-input v-model="queryParams.query" placeholder="订单编号、备注" clearable size="small" />
        </el-form-item>
        <el-form-item label="会员查询：" prop="queryCustomer">
          <el-input v-model="queryParams.queryCustomer" placeholder="姓名、手机号" clearable size="small" />
        </el-form-item>
        <el-form-item label="交易类型：" prop="type">
          <el-select v-model="queryParams.type" placeholder="全部" size="small">
            <el-option v-for="item in typeList" :key="item.id" :label="item.value" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="交易时间：" prop="date">
          <el-date-picker v-model="date" start-placeholder="开始日期" end-placeholder="结束日期" :clearable="false"
            type="daterange" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 380px">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="listBox">
      <div class="topBtn" style="margin-bottom: 14px">
        <div>
          <export-excel-button title="资金流水明细" action="/shenye/bill/export" :params="ExportParams" />
        </div>
      </div>
      <el-table v-loading="loading" :data="customerList" stripe border>
        <el-table-column label="序号" type="index" width="55" align="center" fixed />
        <el-table-column label="订单编号" align="center" prop="orderNo" :show-overflow-tooltip="true" />
        <el-table-column label="手机号" align="center" prop="customerPhone" :show-overflow-tooltip="true" />
        <el-table-column label="用户姓名" align="center" prop="customerName" :show-overflow-tooltip="true" />
        <el-table-column label="交易类型" align="center" prop="type" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="typeList" :value="scope.row.type" />
          </template>
        </el-table-column>
        <el-table-column label="交易金额(￥)" align="center" prop="payMoney" :show-overflow-tooltip="true" />
        <el-table-column label="交易时间" align="center" prop="transactionTime" :show-overflow-tooltip="true" />
        <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />

    </div>
  </div>

</template>

<script>
  import {
    adminDict,
    shenyeBillList,
  } from "@/api/syFundManagement/capitalFlowDetails";
  import ExportExcelButton from "@/components/ExportExcelButton/index";
  export default {
    name: "Customer",
    components: {
      ExportExcelButton,
    },
    data() {
      return {
        id: '',
        pathType: 'add',
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 表格数据
        customerList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          query: '', //关键词 订单编号、备注
          queryCustomer: '', //会员查询 姓名、手机号
          transactionEndTime: '', //交易结束时间
          transactionStartTime: '', //交易开始时间
          type: '', //交易类型 shenye_bill_type 1 NFR购买 2盲盒购买 3宝箱退款 4宝箱购买 5集市兑换 6转赠手续费
        },
        date: [],
        typeList: [{ //交易类型数组
          id: '',
          value: '全部',
        }, ],
      };
    },
    computed: {
      ExportParams() {
        const params = {
          ...this.queryParams,
        };
        return params;
      },
    },
    created() {
        this.getadminDict()
      this.getList();
    },
    methods: {
      getadminDict() {
        //获取交易类型字典
        const params = {
          dictType: "shenye_bill_type",
        };
        adminDict(params).then((res) => {
          this.typeList = this.typeList.concat(res.result[0].dictList);
        });
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        shenyeBillList(this.queryParams).then(response => {
          this.total = response.result.total
          this.customerList = response.result.records
          this.loading = false;

        }).finally(() => {
          this.loading = false;
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.transactionStartTime = this.date[0];
        this.queryParams.transactionEndTime = this.date[1];
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.date = []
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          query: '', //关键词 订单编号、备注
          queryCustomer: '', //会员查询 姓名、手机号
          transactionEndTime: '', //交易结束时间
          transactionStartTime: '', //交易开始时间
          type: '', //交易类型 shenye_bill_type 1 NFR购买 2盲盒购买 3宝箱退款 4宝箱购买 5集市兑换 6转赠手续费
        }
        this.handleQuery();
      },
    }
  };

</script>
<style lang="scss" scoped>
  .head {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px 0;

  }

  .head_st {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    border-radius: 8px;
    margin-bottom: 14px;
    background: #F3F5F7;
  }

  .card_d {
    // width: 420px;
    padding: 0 0px 0 20px;
    height: 100px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    margin-right: 14px;
    background-color: #fff;
    margin-bottom: 10px;

    .list {
      display: flex;
      flex-direction: column;
      flex: 1;
      align-items: center;
      justify-content: center;
      margin-right: 20px;

      p:nth-child(1) {
        font-size: 20px;
        font-weight: bold;
        color: #555;

      }

      p:nth-child(2) {
        font-size: 18px;
        color: #555;
        margin-top: 20px;
      }
    }
  }

  .listBox {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    //   height: 120px;
    padding: 20px 20px;
    margin-top: 10px;
  }

  .topBtn {
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

</style>
